<template>
  <a-card :bordered="false" v-if='result'>
      <div @click="closeCurrent()" style="text-align: right;">
        <a-icon type="close-circle" :style="{ fontSize: '20px', color: '#ccc' }" />
      </div>    
      <detail-list title="基础信息" :col="4" >
        <detail-list-item term="报警时间">{{result.createTime}}</detail-list-item>
        <detail-list-item term="报警位置">{{result.alarmLocation}}</detail-list-item>
        <detail-list-item term="报警编号">{{result.alarmDeviceCode}}</detail-list-item>
        <detail-list-item term="报警级别">{{result.alarmLevel=='一级'?'故障':'报警'}}</detail-list-item>
        <!-- <detail-list-item term="报警类型">{{result.alarmCategory}}</detail-list-item> -->
        <!-- <detail-list-item term="故障类型">{{result.faultType}}</detail-list-item> -->
        <detail-list-item term="报警名称">{{result.faultType}}</detail-list-item>
        <detail-list-item term="处理状态">{{result.status==1?'已处理':'未处理'}}</detail-list-item>
      </detail-list>
      <a-divider/>
      <div class="title-text"> 诊断分析</div>
      <div style="display:flex;">
        <span>报警原因：</span>
        <a-input style="width:70%;" type="textarea" :value="result.description" disabled :auto-size="{ minRows: 3, maxRows: 5 }"></a-input>
      </div>
      <a-divider/>
      <div class="title-text"> 维护建议</div>
      <span>建议编号：{{result.suggestCode}}</span>
      <div style="display:flex;margin-top: 20px;">
        <span>建议内容：</span>
        <a-input style="width:70%;" type="textarea" :value="result.content" disabled :auto-size="{ minRows: 3, maxRows: 5 }"></a-input>
      </div>
      <a-divider/>
      <a-row type="flex" justify="end">
        <a-col>
          <a-button style="margin-right:20px" @click="handleClose">关闭</a-button>
          <a-button type="primary" @click='handleDone' v-if='result.status==0'>确认已处理</a-button>
        </a-col>
      </a-row>
  </a-card>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
  import DetailList from '@/components/tools/DetailList'
  const DetailListItem = DetailList.Item

  export default {
    name: 'GdDeviceFaultAlarmForm',
    inject:['closeCurrent'],
    components: {
      JDictSelectTag,
      DetailList ,
      DetailListItem     
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
     
        },
        result:null
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
      let id = this.$route.query.id
      this.getDetail(id)
    },
    methods: {
      getDetail(id){
        getAction('/fault/gdDeviceFaultAlarm/queryDetailById',{id}).then(res=>{
          if(res&&res.code==200){
            this.result = res.result
            console.log('详情==》',res.result)
          }else {
            this.$message.info("暂无数据")
          }
        })
      },
      handleDone() {
        getAction('/fault/gdDeviceFaultAlarm/faultAlarmHandling',{'id':this.result.id}).then(res=>{
          if(res&&res.code==200){
            this.$message.success(res.message)
            this.closeCurrent()
            this.$router.push('/fault/faultWarningList')
          }
        })
      },  
      handleClose(){
        this.closeCurrent()
        this.$router.push('/fault/faultWarningList')
      }    

    }
  }
</script>
<style lang="less" scoped>
.title-text {
  font-size: 16px;
  color: #000;
  font-weight: 700;
  margin-bottom: 20px;
}
 /deep/ .detail-list {
  .title{
  color: #000;
  font-weight: 700;

  }
}
</style>